package scheduledtasks;


import org.springframework.stereotype.Service;
import scheduledtasks.entity.TaskObj;


@Service
public class ParseImpl implements ParseCorn {

    @Override
    public boolean parse(TaskObj taskObj) {
        Long time=0l;
        String corn=taskObj.getCron();
        String co[]=corn.split(" ");

        /*miao*/
        if(!co[0].trim().equals("*")){
            time=time+Integer.valueOf(co[0].trim())*1000;
        }

        /*分*/
        if(!co[1].trim().equals("*")){
            time=time+Integer.valueOf(co[1].trim())*1000*60;
        }


        /*时*/
        if(!co[2].trim().equals("*")){
            time=time+Integer.valueOf(co[2].trim())*1000*60*60;
        }


        /*天2*/
        if(!co[3].trim().equals("*")){
            time=time+Integer.valueOf(co[3])*1000*60*60*24;
        }
        
        if(System.currentTimeMillis()-taskObj.getTime()>=time){
            return true;
        }
        return false;
    }
}
